#include "phypos.h"
#include "trunk_privutils.h"

mrr_phypos* mrr_phypos_new() {

	mrr_phypos *p;

	p = malloc(sizeof(struct mrr_trunk_location));
	memset(p, 0, sizeof(struct mrr_trunk_location));

	return p;
}

inline void mrr_phypos_free(mrr_phypos *pos_ptr) {

	free(pos_ptr);
}

mrr_phypos* mrr_phypos_clone(mrr_phypos *pos_p) {

	mrr_phypos *newpos_p;

	newpos_p = malloc(sizeof(struct mrr_trunk_location));
	memcpy(newpos_p, pos_p, sizeof(struct mrr_trunk_location));

	return newpos_p;
}

void norm_phy_location(mrr_phypos *locp) {

	if (locp->offset < TRUNK_SIZE)
		return;

	int seg;
	seg = locp->offset / TRUNK_SIZE;
	locp->trunkno += seg;
	locp->offset = locp->offset % TRUNK_SIZE;
}

int mrr_phypos_dist31(mrr_phypos *pos1_p, mrr_phypos *pos2_p) {

}

void mrr_phypos_shift31(mrr_phypos *pos_p, int shift) {

	pos_p->offset += shift;
}
